#include "showpicture.h"


showpicture::showpicture(QWidget *parent) :
    QDialog(parent)
{

    setWindowTitle(tr("Picture"));

    connect(quitButton, SIGNAL(clicked()),this,SLOT(quitShowPicture()));

    headLabel = new QLabel;
    PictureName = new QLabel;
    showPicture = new QLabel;

    zoomButton = new QPushButton;
    narrowButton = new QPushButton;
    quitButton = new QPushButton;

    headLabel->setText("Picture View");
    headLabel->setAlignment(Qt::AlignCenter);
    PictureName->setAlignment(Qt::AlignCenter);
    showPicture->setAlignment(Qt::AlignCenter);

    zoomButton->setText("Zoom");
    narrowButton->setText("Narrow");
    quitButton->setText("Exit");

    BtnLayout = new QHBoxLayout;
    AllLayout = new QVBoxLayout;

    BtnLayout->addWidget(zoomButton);
    BtnLayout->addWidget(narrowButton);
    BtnLayout->addWidget(quitButton);


    AllLayout->addWidget(headLabel);
    AllLayout->addWidget(showPicture);
    AllLayout->addWidget(PictureName);
    AllLayout->addLayout(BtnLayout);

    this->setLayout(AllLayout);
}



showpicture::~showpicture()
{
    //delete ui;
}


void showpicture::quitShowPicture(void)
{
    this->close();
}


void showpicture::showBmpPictures(QString &pictureName)
{
    QString picturePath = EVMSSAVEPICTURE + pictureName;
    QImageReader reader(picturePath);
    //reader.setAutoTransform(true);
    reader.setAutoDetectImageFormat(true);
    const QImage newImage = reader.read();
    showPicture->setPixmap(QPixmap::fromImage(newImage));
    PictureName->setText(pictureName);
}
